package com.ay.weixin.interceptor;


import java.io.IOException;

import org.lizar.controller.intercepter.EventExceptionRecorder;
import org.lizar.controller.loader.EventLoader;
import org.lizar.log.Log;
import org.lizar.log.Logger;

import com.ay.weixin.config.group.exception.ProjectNotExists;
import com.ay.weixin.config.group.exception.ProjectVarNotExists;


public class ExceptionCollector implements EventExceptionRecorder{
	private Log log=Logger.newInstance(this.getClass());
	
	@Override
	public void handle(EventLoader el, Exception e) {
		if(e instanceof ProjectNotExists){
			try {
				el.response_to_root("/project/exception/404");
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}else if(e instanceof ProjectVarNotExists){
			try {
				el.response_to_root("/project/var/exception/404");
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}else{
			log.error(el.getRequestPath(),e);
		}
	}
	


	@Override
	public void init_property() throws Exception {
	}
	

}
